package validator

import "regexp"

// ValidationError 验证错误
type ValidationError struct {
    Field   string
    Message string
}

// Validator 验证器接口
type Validator interface {
    Validate() []ValidationError
}

// Common validation patterns
var (
    nqnPattern    = regexp.MustCompile(`^nqn\.\d{4}-\d{2}\..*`)
    namePattern   = regexp.MustCompile(`^[a-zA-Z0-9_-]{1,32}$`)
    ipv4Pattern   = regexp.MustCompile(`^(\d{1,3}\.){3}\d{1,3}$`)
    portPattern   = regexp.MustCompile(`^\d{1,5}$`)
)

// ValidateNQN 验证NQN格式
func ValidateNQN(nqn string) bool {
    return nqnPattern.MatchString(nqn)
}

// ValidateName 验证名称格式
func ValidateName(name string) bool {
    return namePattern.MatchString(name)
}

// ValidateIPv4 验证IPv4地址
func ValidateIPv4(ip string) bool {
    return ipv4Pattern.MatchString(ip)
}

// ValidatePort 验证端口号
func ValidatePort(port string) bool {
    return portPattern.MatchString(port)
}
